package com.cy.common.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.DelegatingFilterProxy;

/**  
 * @Title:  SpringWebConfig.java   
 * @Package com.cy.pj.common.config   
 * @Description:    描述   
 * @author: ZHANGSIMIN     
 * @date:   2019年10月18日 下午4:59:39   
 * @version V1.0 
 */
@Configuration
public class SpringWebConfig {
	//注册filter对象
		@SuppressWarnings({ "rawtypes", "unchecked" })
		@Bean
		public FilterRegistrationBean  newFilterRegistrationBean() {
			//1.构建过滤器的注册器对象
			FilterRegistrationBean fBean=
		    new FilterRegistrationBean();
			//2.注册过滤器对象
			DelegatingFilterProxy filter=
			new DelegatingFilterProxy("shiroFilterFactory");
			fBean.setFilter(filter);
			//3.进行过滤器配置
			//配置过滤器的生命周期管理(可选)由ServletContext对象负责
			//fBean.setEnabled(true);//默认值就是true
			fBean.addUrlPatterns("/*");
			//....
			return fBean;
		}
		
		
}
